#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
//double ADD(int x)
//{
//	double ret = 0.0;
//	if (x % 2 == 0)
//	{
//		for (int i = x;i >= 2;i -= 2)
//		{
//			ret += (1.0 / i);
//		}
//	}
//	else
//	{
//		for (int i = x;i >=1 ;i -= 2)
//		{
//			ret += (1.0 / i);
//		}
//	}
//	return ret;
//}
 struct man
{
	char name[20];
	int age;
};
 int cmp(const void* pa,const void* pb)
 {
	 /*return strcmp(((struct man*)pa)->name, ((struct man*)pb)->name);*/
	 return ((struct man*)pa)->age - ((struct man*)pb)->age;
 }
int main()
{
	
	struct man person[3] = { {"zhangsan",9 }, {"lisi", 5},{ "wangwu", 6}};
	
	struct man* pa = person;
	//qsort(person, sizeof(person) / sizeof(person[0]), sizeof(person[0]), cmp);
	/*qsort(person, sizeof(person) / sizeof(person[0]), sizeof(person[0]), cmp);*/
	for (int i = 0;i < 3;i++)
	{
		printf("%s %d\n",(pa+i)->name,(pa+i)->age );
	}
	return 0;
}
//#include<stdio.h>
//#include<stdlib.h>
//struct Student {
//	int xuehao;
//	char name[20];
//	float score;
//};
//int paixu(const void* a, const void* b)
//{
//	struct Student* aa = (struct Student*)a;
//		struct Student* bb = (struct Student*)b;
//		return (aa->score < bb->score ? 1 : -1);
//}
//int main()
//{
//	struct Student chucun[5] = { {10101,"Zhang",78},{10103,"Wang",98.5},{10106,"Li",86},{10108,"Ling",73.5},{10110,"Fun",100} };
//	qsort(chucun, 5, sizeof(chucun[0]), paixu);
//	int i;
//	for (i = 0; i < 5; i++)
//	{
//		printf("%d %s %.2f\n", chucun[i].xuehao, chucun[i].name, chucun[i].score);
//	}
//	return 0;
//}